<?php
namespace Home\Controller;
use Think\Controller;
header("Content-Type:text/html; charset=utf-8");
class ProductController extends Controller {
      public function indexAction(){
      	$keyword=trim(I('keyword'));
      	//print_r($keyword);exit('111');
      	$key=trim(I('key'));
			if($keyword){	 		 
				$where=" title REGEXP  '^".$keyword."'";
				$re =M('product')->where($where)->order('id desc')->select();	
				//echo M()->_sql();exit;	
				 }else {
				 		if($key){	 		
						$where=" title LIKE '%".$key."%' or clone LIKE '%".$key."%' or huohao LIKE '%".$key."%'";
						$re =M('product')->where($where)->order('id desc')->select();		
						 }else {
						 		$re=M('product')->order('id desc')->select();
						 }
				 }
				$this->assign('kw',$keyword);
			$this->assign('list',$re);
     		$this->display();
       
    }
	   public function productAction(){
      	$id=I('id');	
				$re=M('product')->where("id=".$id)->find();			
				$this->assign('list',$re);
     		$this->display();
       
    }

  
  
}